namespace Infrastructure.Redis
{
    /// <summary>
    /// Redis配置选项
    /// </summary>
    public class RedisOptions
    {
        /// <summary>
        /// Redis主机
        /// </summary>
        public string Host { get; set; } = "localhost";
        
        /// <summary>
        /// Redis端口
        /// </summary>
        public int Port { get; set; } = 6379;
        
        /// <summary>
        /// Redis连接字符串（如果设置，将优先使用此值）
        /// </summary>
        public string? ConnectionString { get; set; }
        
        /// <summary>
        /// 默认数据库索引
        /// </summary>
        public int DefaultDatabase { get; set; } = 0;
        
        /// <summary>
        /// 连接超时时间（毫秒）
        /// </summary>
        public int ConnectTimeout { get; set; } = 5000;
        
        /// <summary>
        /// 操作超时时间（毫秒）
        /// </summary>
        public int SyncTimeout { get; set; } = 10000;
        
        /// <summary>
        /// 是否使用SSL连接
        /// </summary>
        public bool UseSsl { get; set; } = false;
        
        /// <summary>
        /// 密码
        /// </summary>
        public string? Password { get; set; }
        
        /// <summary>
        /// 重试次数
        /// </summary>
        public int RetryCount { get; set; } = 3;
        
        /// <summary>
        /// 重试间隔（毫秒）
        /// </summary>
        public int RetryDelay { get; set; } = 200;
        
        /// <summary>
        /// 键前缀
        /// </summary>
        public string KeyPrefix { get; set; } = string.Empty;
        
        /// <summary>
        /// 获取完整的连接字符串
        /// </summary>
        /// <returns>Redis连接字符串</returns>
        public string GetConnectionString()
        {
            return !string.IsNullOrEmpty(ConnectionString) ? ConnectionString : $"{Host}:{Port}";
        }
    }
} 